home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / dviware / dvitovdu32 / src / pascal / vis500vdu.p < prev    next >
Text File  |  1991-11-10  |  6KB  |  193 lines

  1. (* VDU routines for a VIS500 terminal. *)
  2.  
  3. #include 'globals.h';
  4. #include 'screenio.h';
  5. #include 'vdu.h';
  6. #include 'tek4010vdu.h';
  7.  
  8. (******************************************************************************)
  9.  
  10. PROCEDURE StartText;
  11.  
  12. (* We are about to draw text in dialogue region. *)
  13.  
  14. BEGIN
  15. TEK4010StartText;
  16. END; (* StartText *)
  17.  
  18. (******************************************************************************)
  19.  
  20. PROCEDURE MoveAbs (row, col : INTEGER);
  21.  
  22. (* Assuming we are in VT52 mode (Alphanumeric mode), move the cursor to the
  23.    given row and column.  Since DVItoVDU assumes top left corner of screen
  24.    is (row=1,col=1) we need to subtract 1 from both coordinates to get
  25.    the actual VT52 position on the screen.
  26. *)
  27.  
  28. BEGIN
  29. WriteChar(ESC); WriteChar('Y');
  30. WriteChar(CHR(ORD(' ') + row - 1));
  31. WriteChar(CHR(ORD(' ') + col - 1));
  32. END; (* MoveAbs *)
  33.  
  34. (******************************************************************************)
  35.  
  36. PROCEDURE MoveToTextLine (line : INTEGER);
  37.  
  38. (* Move current position to start of given line. *)
  39.  
  40. BEGIN
  41. WriteChar(CAN);
  42. MoveAbs(line,1);
  43. END; (* MoveToTextLine *)
  44.  
  45. (******************************************************************************)
  46.  
  47. PROCEDURE ClearTextLine (line : INTEGER);
  48.  
  49. (* Erase given line; note that DVItoVDU does not assume anything about the
  50.    current position at the end of this routine.
  51. *)
  52.  
  53. BEGIN
  54. WriteChar(CAN);           (* switch to Alphanumeric mode *)
  55. MoveAbs(line,1);          (* move to start of line *)
  56. WriteChar(ESC);
  57. WriteChar('K');           (* erase to end of line *)
  58. END; (* ClearTextLine *)
  59.  
  60. (******************************************************************************)
  61.  
  62. PROCEDURE ClearScreen;
  63.  
  64. BEGIN
  65. WriteChar(CAN);           (* enable Alphanumeric display *)
  66. WriteChar(ESC);
  67. WriteChar('H');           (* move to top left of screen *)
  68. WriteChar(ESC);
  69. WriteChar('J');           (* erase to end of screen (Alphanumeric text) *)
  70. TEK4010ClearScreen;       (* erase graphics *)
  71. END; (* ClearScreen *)
  72.  
  73. (******************************************************************************)
  74.  
  75. PROCEDURE StartGraphics;
  76.  
  77. (* We are about to draw in window region. *)
  78.  
  79. BEGIN
  80. TEK4010StartGraphics;
  81. END; (* StartGraphics *)
  82.  
  83. (******************************************************************************)
  84.  
  85. PROCEDURE LoadFont (fontname : string;
  86.                     fontsize : INTEGER;
  87.                     mag, hscale, vscale : REAL);
  88.  
  89. BEGIN
  90. TEK4010LoadFont(fontname,fontsize,mag,hscale,vscale);
  91. END; (* LoadFont *)
  92.  
  93. (******************************************************************************)
  94.  
  95. PROCEDURE ShowChar (screenh, screenv : INTEGER;
  96.                     ch : CHAR);
  97.  
  98. (* The TEK4010 Terse mode characters on the VIS500 need to be dragged down
  99.    so that any descenders will be below the baseline represented by screenv.
  100. *)
  101.  
  102. BEGIN
  103. screenv := screenv + dragdown;
  104. IF screenv > 779 THEN
  105.    TEK4010ShowChar(screenh, 779, ch)   (* drag down as far as possible *)
  106. ELSE
  107.    TEK4010ShowChar(screenh, screenv, ch);
  108. END; (* ShowChar *)
  109.  
  110. (******************************************************************************)
  111.  
  112. PROCEDURE ShowRectangle (screenh, screenv,          (* top left pixel *)
  113.                          width, height : INTEGER;   (* size of rectangle *)
  114.                          ch : CHAR);                (* black pixel *)
  115.  
  116. (* Display the given rectangle. *)
  117.  
  118. VAR pos : INTEGER;
  119.  
  120. BEGIN
  121. IF height = 1 THEN BEGIN            (* show row vector *)
  122.    pos := 779 - screenv;
  123.    WriteChar(GS);
  124.    SendXY(screenh,pos);             (* move cursor to start of row *)
  125.    SendXY(screenh+width-1,pos);     (* draw vector to end of row *)
  126. END
  127. ELSE IF width = 1 THEN BEGIN        (* show column vector *)
  128.    pos := 779 - screenv;
  129.    WriteChar(GS);
  130.    SendXY(screenh,pos);             (* move cursor to start of column *)
  131.    SendXY(screenh,pos-height+1);    (* draw vector to end of column *)
  132. END
  133. ELSE BEGIN
  134.    (* assume height and width > 1; draw and fill rectangle *)
  135.    pos := 779 - (screenv+height-1);
  136.    WriteChar(ESC);         WriteChar('/');
  137.    WriteInt(screenh);      WriteChar(';');   (* left *)
  138.    WriteInt(pos);          WriteChar(';');   (* bottom *)
  139.    WriteInt(width-1);      WriteChar(';');
  140.    WriteInt(height+1);     WriteChar('y');
  141.    (* Note that there are a few problems with this command:
  142.       - we need to subtract 1 from width.  While this prevents exceeding the
  143.         right edge (reason unknown), it causes missing pixel columns.
  144.       - we need to ADD 1 to height to avoid missing pixel rows.
  145.       - the smallest rectangle drawn is 2 by 2.
  146.       - the new cursor position is undefined.
  147.       These funnies are outweighed by the improved efficiency in drawing large
  148.       rectangles.
  149.    *)
  150.    havesentxy := FALSE;   (* need to re-synch cursor position *)
  151. END;
  152. END; (* ShowRectangle *)
  153.  
  154. (******************************************************************************)
  155.  
  156. PROCEDURE ResetVDU;
  157.  
  158. BEGIN
  159. WriteChar(CAN);         (* make sure terminal is in Alphanumeric mode *)
  160. END; (* ResetVDU *)
  161.  
  162. (******************************************************************************)
  163.  
  164. PROCEDURE InitVDU;
  165.  
  166. (* The main program only calls this routine after it has parsed the command
  167.    line and successfully opened the given DVI file.
  168. *)
  169.  
  170. BEGIN
  171. InitTEK4010VDU;
  172. DVIstatusl    := 1;      (* DVItoVDU assumes top text line = 1 *)
  173. windowstatusl := 2;
  174. messagel      := 3;
  175. commandl      := 4;
  176. bottoml       := 33;     (* also number of text lines on VIS500 screen *)
  177. (* The above values assume the VIS500 is in Alphanumeric mode;
  178.    the following values assume it is emulating a Tektronix 4010.
  179.    Note that windowv must be given a value using DVItoVDU's coordinate scheme
  180.    where top left pixel is (0,0).
  181. *)
  182. windowv  := 92;          (* approx. height in TEK4010 pixels of 4 text lines;
  183.                             i.e. 4 * 780/34 *)
  184. windowh  := 0;
  185. windowht := 780-windowv;
  186. windowwd := 1024;
  187.  
  188. WriteChar(GS);
  189. WriteChar(ESC);
  190. WriteChar('@');          (* solid fill for rectangular draw and fill *)
  191. WriteChar(CAN);
  192. END; (* InitVDU *)
  193.